#pragma once
#include "pch.h"

class CPositionBasedDynamics
{
public:
	static bool init_ShapeMatchingConstraint(
		const Eigen::Vector3d x0[], const double invMasses[], const int numPoints,
		Eigen::Vector3d &restCm, Eigen::Matrix3d &invRestMat);

	static bool solve_ShapeMatchingConstraint(
		const Eigen::Vector3d x0[], const Eigen::Vector3d x[], const double invMasses[], const int numPoints,
		const Eigen::Vector3d &restCm,
		const Eigen::Matrix3d &invRestMat,
		const double stiffness[],
		Eigen::Vector3d corr[],
		Eigen::Matrix3d& voRotationMatrix);

	static bool solve_DistanceConstraint(
		const Eigen::Vector3d &p0, double invMass0,
		const Eigen::Vector3d &p1, double invMass1,
		const double restLength,
		const double compressionStiffness,
		const double stretchStiffness,
		Eigen::Vector3d &corr0, Eigen::Vector3d &corr1);
	
	static bool solve_VolumeConstraint(
		const Eigen::Vector3d &p0, double invMass0,
		const Eigen::Vector3d &p1, double invMass1,
		const Eigen::Vector3d &p2, double invMass2,
		const Eigen::Vector3d &p3, double invMass3,
		const double restVolume,
		const double negVolumeStiffness,
		const double posVolumeStiffness,
		Eigen::Vector3d &corr0, Eigen::Vector3d &corr1, Eigen::Vector3d &corr2, Eigen::Vector3d &corr3);
};